Multiple level undo/redo mechanism

ABSTRACT

A multiple-level undo/redo mechanism is provided in an operating system and is available to application programs run on the operating system. The dating system provides a mechanism for keeping a log of user commands and providing a cursor to a position within the log. Each command may be encapsulated into an object that supports an interface for performing undo/redo operations. Similarly, the log may be encapsulated into an object that supports operations that facilitate a multiple-level undo/redo. A user may perform a single undo/redo operation, multiple successive undo/redo operations or complete undo/redo operations.

TECHNICAL FIELD

The present invention relates generally to data processing systems and,more particularly, to a mechanism for providing a multiple levelundo/redo capability in operating systems and application programs.

BACKGROUND OF THE INVENTION

A single-level undo mechanism is provided by software packages, such asthe Microsoft Word, version 5.0, word processing package, which is soldby Microsoft Corporation of Redmond, Washington. The single level undomechanism allows a user command to be undone (i.e., the effects of thesand are reversed) after the command has already been performed. Theundo command is typically performed by selecting a menu item that liststhe undo command as an option. The user is limited to a single level ofundoing of commands and, thus, can only reverse the most recentlyexecuted command.

SUMMARY OF THE INVENTION

In accordance with a first aspect of the present invention, a method ispracticed in a data processing system having memory means and at leastone processor that is responsive to user commands. In this method, a logof user commands that were executed by the processor is stored in thememory means. A first user command stored in a log is undone so as toreverse the effect of the first user command. Subsequently, a next usercommand stored in the log is undone so as to reverse the effect of thenext sequential user command.

In accordance with another aspect of the present invention, a log of atleast two user commands is stored in the memory means. User commandsstored in the log are undone so as to reverse the effects of at leasttwo user commands. At least two of the undone user commands are thenredone so as to again execute those commands.

In accordance with a further aspect of the present invention, a list ofa plurality of user commands is stored in the memory means in a sequenceranging from a selected user command that has been executed by aprocessor to a most recently executed user command. The effects of allof the user commands stored in a sequence of the list are undone so asto return the processor to reverse the effects of the user commands inthe sequence.

In accordance with still another aspect of the present invention, a listof a plurality of user commands is stored in the memory means. The listincludes user commands that have been undone. The user commands thathave been undone are again executed by the processor.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of a data processing system for practicing apreferred embodiment of the present invention.

FIG. 2 is a block diagram illustrating a command element object that isused in the preferred embodiment of the present invention.

FIGS. 3a, 3b and 3c illustrate elements of a user interface forimplementing the multiple-level undo/redo mechanism of the preferredembodiment of the present invention.

FIG. 4a is a flowchart illustrating the steps performed when a userenters a command in the preferred embodiment of the present invention.

FIG. 4b is a diagram illustrating the state of the list of commandelement objects after commands are added in the preferred embodiment ofthe present invention.

FIG. 4c diagram illustrating the list of command elements objects when adeletion of an element on the list is performed in the preferredembodiment of the present invention.

FIG. 5a is a flowchart illustrating the steps performed in an undooperation in the preferred embodiment of the present invention

FIG. 5b is a diagram illustrating a list of command element objects whenundo operations are performed in the preferred embodiment of the presentinvention.

FIG. 6a is a flowchart illustrating the steps performed when a redooperation is performed in the preferred embodiment of the presentinvention.

FIG. 6b is a diagram illustrating the list of command element objectswhen a redo operation is performed in the preferred embodiment of thepresent invention.

FIG. 7a is a flowchart illustrating the steps performed when an undo“All the Way” operation is performed in the preferred embodiment of thepresent invention.

FIG. 7b is a diagram illustrating the list of command element objectswhen an undo “All the Way” operation is performed in the preferredembodiment of the present invention.

FIG. 8a is a flowchart illustrating the steps performed when a redo “Allthe Way” operation is performed in the preferred embodiment of thepresent invention.

FIG. 8b is a diagram illustrating the list of command element objectswhen a redo “All the Way” operation is performed in the preferredembodiment of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

The preferred embodiment of the present invention provides a mechanismfor performing multiple-level undo/redo operations in an applicationprogram. The mechanism keeps a log of user commands and maintains acurrent position in the log to monitor a current state of theapplication program. The log is used by the mechanism to facilitatemultiple-level undo operations and multiple-level redo operations.

FIG. 1 shows a block diagram of a data processing system 10 suitable forimplementing the preferred embodiment of the present invention. The dataprocessing system 10 includes a central processing unit (CPU) 12 and amemory 14. The memory 14 holds application programs 22, an operatingsystem 24 and other items. The data processing system 10 also includes akeyboard 16, a mouse 18 and a video display 20. The data processingsystem 10 shown in FIG. 1 is a conventional single processor system.Nevertheless, it should be appreciated that the present invention mayalso be implemented in a distributed system or in other environments.

The preferred embodiment of the present invention is designed for use inan object-oriented programming environment. For purposes of thediscussion below, it is assumed that the operating system 24 is anobject-oriented operating system. Those skilled in the art willappreciate, however, that the present invention is not limited to use inan object-oriented operating system. Instead, it may also be implementedin other embodiments.

The object-oriented operating system 24 supports the use of “objects” inthe data processing system 10. An object may be viewed as a combinationof data members and, member functions. The data members are attributesthat are stored in data structures, and the member functions arefunctions that act upon these attributes. The notion of an object isexploited in the multiple-level undo/redo mechanism of the preferredembodiment of the present invention in that certain aspects of thismechanism are implemented as objects.

An interface is a group of schematically-related functions that areorganized into a named unit. Each interface may be uniquely identifiedby its identifier. Interfaces have no instantiation, that is aninterface definition does not include code for implementing thefunctions that are specified in the interface. Interfaces specify a setof signatures for functions. An object may “support” an interface. Whenan object supports an interface, the object provides code for thefunction specified by the interface. The code supplied by the object,however, must comply with the signatures specified by the interface.

The multiple-level undo/redo mechanism of the preferred embodiment ofthe present invention supports the ability for an application program tomaintain a command log of user commands. The data held in the commandlog and functions for maintaining the data are encapsulated into acommand log object. The command log object includes a list 30 (see FIG.4b) of command element objects and a cursor 32. The list 30 of commandelement objects is a sequential list of command element objectsspecifying user commands. The cursor 32 specifies a current positionthat corresponds with the last applied (i.e., last exceed) command onthe list 30 of command element objects.

Each command entered by a user during the course of execution of anapplication program 24 generates an associated command element object40, like that shown in FIG. 2. The command element object 40 includes afield 44 that specifies the nature of the command and a V-pointer 42.The V-pointer 42 points to a V-table 46 (i.e., having a virtual tablesuch as found in the C++ programming language) having entries for theoperations that may be performed on the command element object 40. Theseoperations include an undo operation, a redo operation and a mergeoperation, for which respective entries 48a, 48b and 48c are provided.Entries 48a, 48b and 48c point to sections of code 50a, 50b and 50c forimplementing their associated operations. The undo operation undoes thecommand at the current cursor position. The redo operation performs thenext operation on the list 30 (FIG. 4b). The merge operation mergescommand log element objects, if possible.

The command log object does not need to know about the implementation ofthe code 50a, 50b and 50c for implementing operations on the commandelement objects 40. The details of this code 50a, 50b and 50c are theconcern of the command element objects 40. As such, the command logobject can be implemented more easily since it does not need to concernitself with such details.

The command log object and the command element object 40 are created bythe application program 22 (FIG. 1). The operating system 24 provides amulti-level undo/redo facility to support multiple undo/redo operationsfor the application program. Part of this mechanism is a user interface.The user interface displays buttons 51 and 53 (FIG. 3a) that may beactivated to cause execution of undo and redo commands, respectively.The undo button 51 and the redo button 53 may be activated multipletimes to perform multiple undos or redos consecutively. The user is notlimited to undoing only a most recent command or redoing a most recentlyundone command. A context menu 55 is provided for the undo button 51when activated (see FIG. 3b). A similar context menu 57 (FIG. 3c) isprovided for the redo button. The context menus 55 (FIG. 3b) and 57(FIG. 3c) provide two options: “Last Applied” and “All The Way.” Theseoptions cause either only a single last applied command to beundone/redone or the commands to be undone/redone.

The four operations provided by the multiple-level undo/redo mechanismof the preferred embodiment of the present invention are perhaps bestexplained by way of example. As such, examples will be provided belowalong with the steps performed by the preferred embodiment for each ofthe respective four operation types.

FIG. 4a is a flowchart illustrating the steps performed by the preferredembodiment of the present invention when a user enters a new command.FIG. 4a will be described in conjunction with the diagram of FIG. 4b.FIG. 4b depicts an example of the list 30 of command element objects.Initially, a user enters a command (step 52 in FIG. 4a). In the exampleof FIG. 4b, the list 30 is initially empty. Suppose that the user thenenters command “a”. The multiple level undo/redo mechanism of thepreferred embodiment then checks whether there are any commands on thelist before the cursor 32 (step 54 in FIG. 4a). If there are no commandson the list before the cursor 32, such as in the case shown in FIG. 4b,the command is added to the front of the list 30 (step 58 in FIG. 4a),and the cursor is moved to point to the front of the list (step 60).Thus, as shown in FIG. 4b, after command “a” is entered, an entry 64(i.e., an entry for a command element object for command “a”) is addedto the front of the list 30 and the cursor 32 is moved to point to entry64. Suppose that the user now enters another command “b”, (hence,repeating step 52 of FIG. 4a). Steps 54, 58 and 60 of FIG. 4a are thenrepeated so that an entry 66 (FIG. 4b) is added to the front of the list30 before the entry 64 for command “a”. Cursor 32 is updated to point toentry 66 for command “b”.

In the above-described fashion, the list 30 of command element objectsis built. In terms of the object model described above, each time a userenters a command, an instance of a command element object 40 (FIG. 2) iscreated; the new command element object is appended to the front of thelist; and the cursor position is updated.

If in step 54 of FIG. 4a it is determined that there are commands on thelist 30 that are situated before the cursor 32, all the commands on thelist that are before the cursor are deleted (step 56 in FIG. 4a). FIG.4c shows an example of such a deletion. Suppose that initially list 30of command log elements includes entries 68, 70 and 72 for commands “a”,“b” and “c”, respectively, as shown in FIG. 4c. The cursor 32 points toentry 70 for command “b”. Subsequently, a user enters command “d”. Instep 54 of FIG. 4a, it is determined that entry 72 for command “c” ispositioned before the cursor on list 30. Hence, entry 72 is deleted instep 56 of FIG. 4a. Further, an entry 73 for command “d” is added to thefront of the list 30 (see step 58 in FIG. 4a), and the cursor 32 (FIG.4c) is updated to point to entry 73 (see step 60 in FIG. 4a).

Once a user has built a list 30 of command element objects, such asdescribed above, the user may execute an undo command. FIG. 5a is aflowchart of the steps performed when an undo command is requested. FIG.5b is a diagram illustrating the state of the list 30 of command elementobjects after multiple undo commands are performed on the list. Thesteps of FIG. 5a will be described in conjunction with the diagram ofFIG. 5b. Initially, a user requests an undo operation by activating theundo button 51 (FIG. 3b) provided in the user interface. As wasdescribed above, a context menu 55 is displayed after the button 51 isactivated and the context menu provides the user with the option ofundoing only the most recent command (i.e., the “Last Applied” option).Suppose that the user selects the “Last Applied” option on the contextmenu 55 (step 74 in FIG. 5a). The command pointed to by the cursor 32 isundone by executing code 50a (FIG. 2) that is provided in the commandelement object (step 76) for undoing the command. In addition, thecursor 32 is decremented to point to the next successive entry on thelist 30 of command element objects. To perform multiple-level undooperations, the user activates the undo button 51 multiple times torepeat the above-described steps.

FIG. 5b shows an example of successive undo operations. Suppose thatinitially a list of command element objects includes entries 80, 82 and84 for commands “a”, “b” and “c”, respectively. Further suppose thatcursor 32 points to entry 84. When a user subsequently requests an undooperation, command “c” is undone and the cursor 32 is moved to point toentry 82 for command “b”. If the user makes an additional undo operationrequest, command “b” is also undone, and the cursor is moved to point toentry 80 for command “a”.

A user may also request a single redo operation. FIG. 6a is a flowchartof the steps performed for a since redo operation of a most recentlyundone command. The process begins with a user requesting a redooperation of the most recently undone command. The user activates theredo button 53 (FIG. 3c) from the user interface and then chooses the“Last Applied” option from the context menu 57 (step 86 in FIG. 6a). Thecommand immediately in front of the current cursor position on list 30is then performed (step 88), and the cursor is incremented (step 90). Interms of the object model discussed above with reference to FIG. 2, theredo code 50b is executed on the command element object 40 that was mostrecently undone. To perform multiple-level redo operations, the useractivates the redo button 53 multiple times to repeat the steps of FIG.6a.

FIG. 6b shows an example of the effect of a redo command. Initially, alist 30 includes entries 92 and 94 for commands “a” and “b”,respectively. Cursor 32 points to entry 92 for command “a”. When theuser enters a redo command, command “b” is again performed and thecursor 32 is incremented to point to entry 94 for command “b”.

The user has the additional option of undoing all commands on the list30 of command element objects. FIG. 7a is a flowchart of the stepsperformed for a undo “All the Way” operation. Initially, a user requeststhat an undo “All the Way” operation be performed (Step 96 in FIG. 7a).The user requests such a command by activating the undo button 51 (FIG.3b) and then selecting the “All the Way” option on the context menu 55.All user commands from the current command to the initial command arereversed (step 98 in FIG. 7a). In addition, the cursor is moved to pointto before the initial command on list 30 (step 100).

FIG. 7b shows an example of the effect of an undo “All the Way”operation. Initially, a list 30 of command element objects 30 includesentries 102, 104 and 106 for commands “a”, “b” and “c”, respectively.The cursor 32 points to entry 106 for command “c”. After the user hasrequested the undo “All the Way” operation, commands “c”, “b” and “a”are sequentially undone, and the cursor 32 is decremented to point tobefore the first entry on the list 30.

A user may, likewise, request that the redo operation be perform “Allthe Way” to redo all of the commands on the list that are situated infront of the current cursor position. FIG. 8a is a flowchart of thesteps performed for such an operation. Initially, the user requests thatthe redo “All the Way” operation be performed (step 108 in FIG. 8a). Aswith the other operations, the user selects the operation through theuser interface. In particular, the user activates the redo button 53 andthen selects the “All the Way” option from the context menu 57 (FIG.3c). After the selection has been made, the commands that are positionedin front of the cursor 32 on the list are performed (step 110 in FIG.8a). In addition, the cursor position is incremented to point to thefront of the list (step 112).

FIG. 8b shows an example that illustrates the effect of the redo “Allthe Way” operation. Initially, a list 30 of command element objectsincludes entries 114, 116 and 118 for commands “a”, “b” and “c”,respectively. The cursor 32 points to entry 114 for command “a.” Afterthe redo “All the Way” operation is performed, commands “b” and “c” havebeen sequentially executed, and the cursor position is incremented topoint to entry 118 for command “c”.

While the present invention has been described with reference to apreferred embodiment thereof, those skilled in the art will,nevertheless, appreciate that various changes in form and detail may bemade without departing from the present invention as defined by theappended claims.

I claim:
 1. In a computer system having a video display and running anoperating system and an application program, a method comprising thecomputer-implemented steps of: providing a multiple level undo/redofacility in the operating system; creating a command element object bythe application program for each associated command that is executed inthe application program, each command element object including a pointerto a V-table that has at least one entry that holds a pointer to codefor undoing or performing the command associated with the commandelement object; linking the command element objects together in asequential list ordered according to when the associated commands wereexecuted; encapsulating the sequential list of lined command elementobjects in a command log object that is provided by the applicationprogram; with the undo/redo facility, displaying an activatableundo/redo user interface element in a window on the video display,wherein the window is provided by the application program; and inresponse to a user activating the undo/redo facility, with the undo/redofacility calling the code that is pointed to by an entry in a V-tablethat is pointed to by a pointer in a selected one of command elementobjects in the sequential list to undo or redo the command associatedwith the selected command element.
 2. The method of claim 1 wherein theundo/redo user interface element is an undo user interface element andthe entry in the V-table pointed to by the pointer in the selectedcommand element object holds a pointer to code for undoing the commandthat is associated with the selected command element object.
 3. Themethod of claim 1 wherein the undo/redo user interface element is a redouser interface element and the entry in the V-table pointed to by thepointer in the selected command element object holds a pointer to codefor performing the command that is associated with the selected commandelement object.
 4. In a computer system that has a video display andthat runs an operating system and an application program, wherein theapplication program provides a command element object for eachassociated command that is executed in the application program and eachcommand element object including a pointer to a V-table that has atleast one entry that holds a pointer for undoing or redoing the commandassociated with the command element object and wherein the applicationprogram encapsulates a sequential list of the command element objectsthat are linked and ordered according to when the associated commandwere executed in a command log object, a computer-readable storagemedium holding instructions for: providing a multiple level undo/redofacility in the operating system; with the undo/redo facility,displaying an activatable undo/redo user interface element in a windowon the video display, where the window is provided by the applicationprogram; and in response to a user activating the undo/redo userinterface element, with the undo/redo facility calling the code that ispointed to by the entry in the V-table pointed to by a pointer in aselected one of command element objects in the sequential list to undoor redo the associated command.
 5. In a computer system having a videodisplay and running both an operating system and an application program,a method comprising the steps of: providing a multiple level undo/redofacility in the operating system; displaying an activatable undo-alluser interface element by the undo/redo facility in a window provided bythe application program or on the video display and which is opened whenaccessing the interface element of the undo/redo facility; where a userhas caused multiple commands of the application program to be executedundoing effects of executing the commands, in response to the useractivating the undo-all user interface element, by the undo/redofacility calling code in the application program for undoing thecommands.
 6. In a computer system having a video display and runningboth an operating system and an application program, a computer-readablestorage medium holding instructions for performing a method comprisingthe steps of: providing a multiple level undo/redo facility in theoperating system; displaying an activatable undo-all user interfaceelement by the undo/redo facility in a window provided by theapplication program on the video display and which is opened whenaccessing the interface element of the undo/redo facility; where a userhas caused multiple commands of the application program to be executed,undoing effects of executing the commands in response to the usesactivating the undo-all user interface element, by the undo/redofacility calling code in the application program for undoing thecommands.
 7. In a computer system having a video display and runningboth an operating system and an application program, a method comprisingthe steps of: providing a multiple level undo/redo facility in theoperating system; with the undo/redo facility, displaying an activatableredo-all user interface for causing all commands of the applicationprogram, that have been undone to be again executed, in a windowprovided by the application program on the video display and which isopened when accessing the interface element of the undo/redo facility;and where a user has undone multiple commands, executing the undonecommands in response to the user activating the redo-all user interfaceelement, by the undo/redo facility calling code for performing thecommands in the application program.
 8. In a computer system having avideo display and running both an operating system and an applicationprogram, a computer-readable storage medium holding instructions forperforming a method comprising the steps of: providing a multiple levelundo/redo facility in the operating system; with the undo/redo facility,displaying an activatable redo-all user interface for causing allcommands of the application program, that have been undone to be againexecuted, in a window provided by the application program on the videodisplay and which is opened when accessing the interface element of theundo/redo facility; and where a user has undone multiple commands,executing the undone commands in response to the user activating theredo-all user interface element, by the undo/redo facility calling codefor performing the commands in the application program.
 9. In a computersystem that has a display and that runs an operating system and anapplication program, wherein the application program provides a commandelement object for each associated command that is executed in theapplication program and wherein the operating system provides a multiplelevel undo/redo facility, a computer-readable storage medium on whichare stored computer-executable instructions for implementing within theapplication program a method which is comprised of: a step for creatingin the application program a list of command element objects which aresequentially ordered corresponding to the order of the commands executedin the application program, each command element object in said listhaving associated with it a means for selectively activating theundo/redo facility in the operating system; a step for accessing theundo/redo facility in order to display an activatable undo/redo userinterface element in a window on the display, wherein the window isprovided by the application program; and a step for using said interfaceelement to select any command element object in said list and inresponse to said selection, the undo/redo facility undoing or redoing asdirected by a user either one or all the commands for all commandelement objects in said list, as selected.
 10. In a computer system thathas a display and that runs an operating system and an applicationprogram, wherein the application program provides a command elementobject for each associated command that is executed in the applicationprogram and wherein the operating system provides a multiple levelundo/redo facility, a method comprised of: a step for creating in theapplication program a list of command element objects which aresequentially ordered corresponding to the order of the commands executedin the application program, each command element object in said listhaving associated with it a means for selectively activating theundo/redo facility in the operating system; a step for accessing theundo/redo facility in order to display an activatable undo/redo userinterface element in a window on the display, wherein the window isprovided by the application program; and a step for using said interfaceelement to select any command element object in said list and inresponse to said selection, the undo/redo facility undoing or redoing asdirected by a user either one or all the commands for all commandelement objects in said list, as selected.
 11. In a computer system thathas a display and that runs an operating system and an applicationprogram, wherein the application program provides a command elementobject for each associated command that is executed in the applicationprogram and wherein the operating system provides a multiple levelundo/redo facility, a computer-readable storage medium on which arestored computer-executable instructions for implementing within theapplication program a method which is comprised of: the step forcreating in the application program a list of command element objectswhich are sequentially ordered corresponding to the order of thecommands executed in the application program, each command elementobject in said list comprising a pointer to computer-executable code forselectively undoing or redoing the command associated with that commandelement object; the act of specifying a cursor position that correspondsto one of the command element objects so that any command elementobjects associated with commands executed in the application programprior to the time for the command associated with the specified cursorposition are identified by virtue of the cursor position; based on thespecified cursor position, the act of deleting from said list anycommand element objects that have already been undone at the time a newcommand is executed by the user in the application program, andthereafter performing the act of appending to the front of said list anew command element object for the newly executed command in theapplication program, and moving the cursor position to that newlyappended command element object; a step for accessing the undo/redofacility in order to display an activatable undo/redo user interfaceelement in a window on the display, wherein the window is provided bythe application program; and a step for using said interface element toselect any command element object in said list and in response to saidselection, the undo/redo facility undoing or redoing as directed by auser either one or all the commands for all command element objects insaid list, as selected.
 12. In a computer system that has a display andthat runs an operating system and an application program, wherein theapplication program provides a command element object for eachassociated command that is executed in the application program andwherein the operating system provides a multiple level undo/redofacility, a method comprised of; the step for creating in theapplication program a list of command element objects which aresequentially ordered corresponding to the order of the commands executedin the application program, each command element object in said listcomprising a pointer to computer-executable code for selectively undoingor redoing the command associated with that command element object; theact of specifying a cursor position that corresponds to one of thecommand element objects so that any command element objects associatedwith commands executed in the application program prior to the time forthe command associated with the specified cursor position are identifiedby virtue of the cursor position; based on the specified cursorposition, the act of deleting from said list any command element objectsthat have already been undone at the time a new command is executed bythe user in the application program, and thereafter performing the actof appending to the front of said list a new command element object forthe newly executed command in the application program and moving thecursor position to that newly appended command element object; a stepfor accessing the undo/redo facility in order to display an activatableundo/redo user interface element in a window on the display, wherein thewindow is provided by the application program; and a step for using saidinterface element to select any command element object in said list andin response to said selection, the undo/redo facility undoing or redoingas directed by a user either one or all commands for all command elementobjects in said list, as selected.